-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ap, LinearSVM, OGD as estimators #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -52,9 +53,10 @@ public abstract class AveragedLinearArguments : OnlineLinearArguments | |||
public Float AveragedTolerance = (Float)1e-2; | |||
} | |||
|
|||
public abstract class AveragedLinearTrainer<TArguments, TPredictor> : OnlineLinearTrainer<TArguments, TPredictor> | |||
public abstract class AveragedLinearTrainer<TArguments, TTransformer, TModel> : OnlineLinearTrainer<TArguments, TTransformer, TModel> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TArguments [](start = 48, length = 10)
I will remove this on the next iteration, together with updating the tests. #Closed
@@ -237,7 +237,7 @@ public interface IEstimator<out TTransformer> | |||
/// <summary> | |||
/// Train and return a transformer. | |||
/// </summary> | |||
TTransformer Fit(IDataView input); | |||
TTransformer Fit(IDataView input, IDataView validationData = null, IPredictor initialPredictor = null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDataView validationData = null, IPredictor initialPredictor = null) [](start = 41, length = 69)
I am not certain I welcome this move. It seems like it is repeating the mistake of IIncrementalValidatingTrainer
, which would be bad enough if it was just for trainers alone but it seems to be for absolutely every estimator. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sfilipi ! To change such a central interface as IEstimator
with a signature like this is not something we should welcome. The argument I made in #509, which I believe is absolutely correct, is that what is fed to a trainer is not something fixed now and forever. We already have beliefs about more things that ought to be given to these things. This is by itself bad enough, but to putting them in an interface specifically is an especially hazardous venture since changes to interfaces between versions is somewhat disastrous. That we're encouraging this on IEstimator
which is, frankly, arguably the most important interface in the entire ecosystem, makes me very nervous. So for this reason I am very, very alarmed.
var secondTrainer = new MyAveragedPerceptron(env, new AveragedPerceptronTrainer.Arguments(), "Features", "Label"); | ||
var finalModel = secondTrainer.Train(trainData, firstModel.Model); | ||
var secondTrainer = new AveragedPerceptronTrainer(env, new AveragedPerceptronTrainer.Arguments()); | ||
var finalModel = secondTrainer.Fit(trainData, initialPredictor: firstModel.Model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fit [](start = 47, length = 3)
@[email protected] if Fit() should not take a validation set, and an initial model, for this example/case here, would we still call Train()?
// Train the second predictor on the same data.
var secondTrainer = new AveragedPerceptronTrainer(env, new AveragedPerceptronTrainer.Arguments());
var trainRoles = new RoleMappedData(trainData, label: "Label", feature: "Features");
var finalModel = secondTrainer.Train(new TrainContext(trainRoles, initialPredictor: firstModel.Model)); #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Pigsty land, I'm not sure how this can be accommodated (or rather should it?)
In Dynamic land, yes, we still call Train, just not with the TrainContext and RoleMappedData
In reply to: 215809082 [](ancestors = 215809082)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Pigsty land, I'm not sure how this can be accommodated (or rather should it?)
Almost certainly, but unless I'm mistaken I don't think changes to IEstimator
, or any of these core interfaces, will be necessary, or indeed even slightly helpful. Indeed, I might be missing something, but I'm a little confused about where we imagine the source of the problem is? We've posited the existence of some hypothetical ITransformer Train(IDataView trainData, ...)
method, so why do we suppose a Transformer<TIn, TOut> Train<TIn, TOut>(DataView<TIn> trainData, ...)
is impossible? Perhaps there's some subtlety I've missed.
In reply to: 215821268 [](ancestors = 215821268,215809082)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain whether that's in scope for this PR. Maybe it is, I just don't know.
In reply to: 215840658 [](ancestors = 215840658,215821268,215809082)
{ | ||
public const string LoadNameValue = "AveragedPerceptron"; | ||
internal const string UserNameValue = "Averaged Perceptron"; | ||
internal const string ShortName = "ap"; | ||
internal const string Summary = "Averaged Perceptron Binary Classifier."; | ||
|
||
internal new readonly Arguments Args; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal [](start = 8, length = 8)
this should truly be private, but our analyzer wants the private properties to be lowercased. This i should change or add a separate rule for 'private new'. Thoughts? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var finalModel = secondTrainer.Train(trainData, firstModel.Model); | ||
var secondTrainer = new AveragedPerceptronTrainer(env, new AveragedPerceptronTrainer.Arguments()); | ||
|
||
var trainRoles = new RoleMappedData(trainData, label: "Label", feature: "Features"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RoleMappedData [](start = 37, length = 14)
wait, wait, RoleMappedData should not survive :) #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I'm fine with keeping them internally for now, but Train
call should take only IDataView
for train data
In reply to: 215820969 [](ancestors = 215820969)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the preferred way of passing the initialPredictor for online learners if neither Train or Fit should take them in as arguments?
In reply to: 215821958 [](ancestors = 215821958,215820969)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zruty0 i added a second TrainContext that contains IDataView for the Training, Validation data, and another Train Method that takes this second TrainContext but that proliferates everywhere in an ugly way.
I think we should keep the RoleMappedData instead of this spawn, and once it goes away, TrainContext will get cleaned up and so will this example. Objections?
In reply to: 215848474 [](ancestors = 215848474,215821958,215820969)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's ok, let's create an issue for that though.
In reply to: 216079699 [](ancestors = 216079699,215848474,215821958,215820969)
@@ -25,10 +25,11 @@ | |||
|
|||
namespace Microsoft.ML.Runtime.Learners | |||
{ | |||
using Microsoft.ML.Core.Data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using [](start = 4, length = 5)
consolidate #Closed
@@ -25,10 +25,11 @@ | |||
|
|||
namespace Microsoft.ML.Runtime.Learners | |||
{ | |||
using Microsoft.ML.Core.Data; | |||
using TPredictor = LinearRegressionPredictor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TPredictor [](start = 10, length = 10)
let's remove this #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sfilipi .
@@ -2,8 +2,11 @@ | |||
// The .NET Foundation licenses this file to you under the MIT license. | |||
// See the LICENSE file in the project root for more information. | |||
|
|||
using Float = System.Single; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @Zruty0 meant remove it altogether, but that's all right, we can do a sweep for this later.
Converting AveragePerceptron, LinearSVM and ODG trainers to estimators.